package com.cskaoyan.javase.exception.handle2.catch2.exercise;

/**
 * @description: 单分支try..catch练习
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

public class Demo {
    public static void main(String[] args) {
        try {
            System.out.println("before");
            System.out.println(10/0);
            System.out.println("after");
        }
        catch (ArithmeticException e){
            System.out.println("发生了异常");
        }
        System.out.println("try..catch之后");
        try {
            System.out.println("before");
            System.out.println(10/0);
            System.out.println("after");
        }
        catch (RuntimeException e){
            System.out.println("发生了异常");
        }
        System.out.println("try..catch之后");
        /*try {
            System.out.println("before");
            System.out.println(10/0);
            System.out.println("after");
        }
        catch (NullPointerException e){
            System.out.println("发生了异常");
        }*/
        System.out.println("try..catch之后");
        try {
            System.out.println("before");
            System.out.println(10/10);
            System.out.println("after");
        }
        catch (NullPointerException e){
            System.out.println("发生了异常");
        }
        System.out.println("try..catch之后");
    }
}
